package m.common.action;

import m.system.lang.HtmlBodyContent;
import m.system.util.JSONMessage;

import java.lang.reflect.Type;

public enum ActionResultType {
    Json(JSONMessage.class),
    VuePage(VueResult.class),
    HtmlPage(HtmlResult.class),
    BodyContent(HtmlBodyContent.class),
    Other(null);
    private Type type;
    ActionResultType(Type t){
        this.type=t;
    }
    public Class<?> getType(){
        return (Class<?>) this.type;
    }
    public boolean isAssignableFrom(Class<?> clazz){
        return this.getType().isAssignableFrom(clazz);
    }
    public static ActionResultType to(Type t){
        for(ActionResultType v : values()){
            if(v.type.equals(t)) return v;
        }
        ActionResultType v=Other;
        v.type=t;
        return v;
    }
}
